import request from "../utils/request"

/**
 * HR创建聊天会话
 * @param {string} candidateId - 候选人用户ID
 */
export const createChatSessionApi = (candidateId) => {
  return request({
    method: 'POST',
    url: `/portal/chat/session/add/hr?candidateId=${candidateId}`,
    data: {}
  })
}

/**
 * 候选人创建聊天会话
 * @param {string} hrId - HR用户ID
 * @param {string} jobId - 职位ID
 */
export const createCandidateChatSessionApi = (hrId, jobId) => {
  return request({
    method: 'POST',
    url: `/portal/chat/session/add/candidate?hrId=${hrId}&jobId=${jobId}`,
    data: {}
  })
}

/**
 * 获取聊天会话列表
 */
export const getChatSessionListApi = () => {
  return request({
    method: 'GET',
    url: '/portal/chat/session/list'
  })
}

/**
 * 发送面试邀请
 * @param {Object} data - 面试邀请数据
 * @param {string} data.positionId - 职位ID
 * @param {string} data.positionName - 职位名称
 * @param {string} data.candidateId - 候选人ID
 * @param {string} data.contactPhone - 联系人电话
 * @param {string} data.remarks - 备注信息
 * @param {string} data.interviewAddress - 面试地址
 * @param {number} data.interviewAddressLng - 面试地址经度
 * @param {number} data.interviewAddressLat - 面试地址纬度
 * @param {string} data.interviewTime - 面试时间 (yyyy-MM-dd HH:mm)
 */
export const sendInterviewInvitationApi = (data) => {
  return request({
    method: 'POST',
    url: '/portal/job/interview/invite',
    data
  })
}

/**
 * 获取面试详情
 * @param {String} interviewId - 面试ID
 * @returns {Promise} 返回面试详情
 */
export const getInterviewDetailApi = (interviewId) => {
  return request({
    method: 'GET',
    url: `/portal/job/interview/detail?interviewId=${interviewId}`
  })
}

/**
 * 候选人接受面试
 * @param {String} interviewId - 面试ID
 * @returns {Promise}
 */
export const acceptInterviewApi = (interviewId) => {
  return request({
    method: 'POST',
    url: `/portal/job/interview/candidate/receive?interviewId=${interviewId}`,
    data: {}
  })
}

/**
 * 候选人拒绝面试
 * @param {String} interviewId - 面试ID
 * @returns {Promise}
 */
export const refuseInterviewApi = (interviewId) => {
  return request({
    method: 'POST',
    url: `/portal/job/interview/candidate/refuse?interviewId=${interviewId}`,
    data: {}
  })
}

/**
 * HR取消面试
 * @param {String} interviewId - 面试ID
 * @returns {Promise}
 */
export const stopInterviewApi = (interviewId) => {
  return request({
    method: 'POST',
    url: `/portal/job/interview/hr/stop?interviewId=${interviewId}`,
    data: {}
  })
}

/**
 * HR获取进行中的面试列表
 * @param {Object} params - 分页参数
 * @param {number} params.pageNo - 页码
 * @param {number} params.pageSize - 页大小
 * @returns {Promise}
 */
export const getHrOngoingInterviewListApi = (params) => {
  return request({
    method: 'GET',
    url: '/portal/job/interview/hr/ongoing',
    params
  })
}

/**
 * HR获取历史面试列表
 * @param {Object} params - 分页参数
 * @param {number} params.pageNo - 页码
 * @param {number} params.pageSize - 页大小
 * @returns {Promise}
 */
export const getHrHistoryInterviewListApi = (params) => {
  return request({
    method: 'GET',
    url: '/portal/job/interview/hr/history',
    params
  })
}

/**
 * Candidate获取进行中的面试列表
 * @param {Object} params - 分页参数
 * @param {number} params.pageNo - 页码
 * @param {number} params.pageSize - 页大小
 * @returns {Promise}
 */
export const getCandidateOngoingInterviewListApi = (params) => {
  return request({
    method: 'GET',
    url: '/portal/job/interview/candidate/ongoing',
    params
  })
}

/**
 * Candidate获取历史面试列表
 * @param {Object} params - 分页参数
 * @param {number} params.pageNo - 页码
 * @param {number} params.pageSize - 页大小
 * @returns {Promise}
 */
export const getCandidateHistoryInterviewListApi = (params) => {
  return request({
    method: 'GET',
    url: '/portal/job/interview/candidate/history',
    params
  })
}

/**
 * HR获取面试总数量
 * @returns {Promise}
 */
export const getHrInterviewCountApi = () => {
  return request({
    method: 'GET',
    url: '/portal/job/interview/hr/count'
  })
}

/**
 * Candidate获取面试总数量
 * @returns {Promise}
 */
export const getCandidateInterviewCountApi = () => {
  return request({
    method: 'GET',
    url: '/portal/job/interview/candidate/count'
  })
}
